home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_068 / mg1b / tty / amiga / console.c next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  115 lines

  1. /*
  2.  * These functions are taken directly from the
  3.  * console.device chapter in the Amiga V1.1
  4.  * ROM Kernel Manual.
  5.  */
  6. #include <exec/types.h>
  7. #include <exec/io.h>
  8. #include <devices/console.h>
  9. #include <libraries/dos.h>
  10. #include <intuition/intuition.h>
  11.  
  12. extern    LONG    OpenDevice();
  13. extern    LONG    DoIO();
  14. extern    LONG    SendIO();
  15.  
  16. /*
  17.  * Open a console device, given a read request
  18.  * and a write request message.
  19.  */
  20.  
  21. int OpenConsole(writerequest,readrequest,window)
  22. struct IOStdReq *writerequest;
  23. struct IOStdReq *readrequest;
  24. struct Window *window;
  25. {
  26.     LONG error; 
  27.     writerequest->io_Data = (APTR) window;
  28.     writerequest->io_Length = (ULONG) sizeof(*window);
  29.     error = OpenDevice("console.device", 0L, writerequest, 0L);
  30.  
  31.     /* clone required parts of the request */
  32.     readrequest->io_Device = writerequest->io_Device;
  33.     readrequest->io_Unit   = writerequest->io_Unit;
  34.     return((int) error);
  35. }
  36.  
  37. /*
  38.  * Output a single character    
  39.  * to a specified console
  40.  */ 
  41.  
  42. int ConPutChar(request,character)
  43. struct IOStdReq *request;
  44. char character;
  45. {
  46. #ifdef    V11
  47.     register int x;
  48. #endif
  49.     request->io_Command = CMD_WRITE;
  50.     request->io_Data = (APTR)&character;
  51.     request->io_Length = (ULONG)1;
  52.     DoIO(request);
  53.     /* caution: read comments in manual! */
  54.     return(0);
  55. }
  56.  
  57. /*
  58.  * Output a NULL-terminated string of
  59.  * characters to a console
  60.  */ 
  61.  
  62. int ConPutStr(request,string)
  63. struct IOStdReq *request;
  64. char *string;
  65. {
  66. #ifdef    V11
  67.     register int x;
  68. #endif
  69.     request->io_Command = CMD_WRITE;
  70.     request->io_Data = (APTR)string;
  71.     request->io_Length = (LONG)-1;
  72.     DoIO(request);
  73.     return(0);
  74. }
  75.  
  76. /*
  77.  * Write out a string of predetermined
  78.  * length to the console
  79.  */
  80.  
  81. int ConWrite(request,string,len)
  82. struct IOStdReq *request;
  83. char *string;
  84. int len;
  85. {
  86. #ifdef    V11
  87.     register int x;
  88. #endif
  89.     request->io_Command = CMD_WRITE;
  90.     request->io_Data = (APTR)string;
  91.     request->io_Length = (LONG)len;
  92.     DoIO(request);
  93.     return(0);
  94. }
  95.  
  96. /*
  97.  * Queue up a read request 
  98.  * to a console
  99.  */
  100.  
  101. int QueueRead(request,whereto)
  102. struct IOStdReq *request;
  103. char *whereto;
  104. {
  105. #ifdef    V11
  106.     register int x;
  107. #endif
  108.     request->io_Command = CMD_READ;
  109.     request->io_Data = (APTR)whereto;
  110.     request->io_Length = (LONG)1;
  111.     SendIO(request);
  112.     return(0);
  113. }
  114.  
  115.